﻿using Inovout.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Inovout.RedictUrls;
using NHibernate.Criterion;
namespace Inovout.RedictUrls
{
    public class RedictUrlRepository : DataObjectRepository<RedirctUrl>
    {
        public RedirctUrl FindByActionUrl(string actionUrl)
        {
            return base.Find(Restrictions.Eq("ActionUrl", actionUrl).IgnoreCase());
        }

        public RedirctUrl FindByOrginalUrlByEamil(string email)
        {
            RedirctUrl entity = new RedirctUrl();
            entity = base.Find(Restrictions.Like("OrginalUrl", email, MatchMode.Anywhere).IgnoreCase());
            return entity;
        }

        public RedirctUrl FindByOrginalUrlByMembershipUserId(int id)
        {
            RedirctUrl entity = new RedirctUrl();
            entity = base.Find(Restrictions.Like("OrginalUrl", "MembershipUser=" + id, MatchMode.Anywhere).IgnoreCase());
            return entity;
        }
    }
}
